package com.iqik.work.service.impl;

import com.iqik.work.mapper.UserMapper;
import com.iqik.work.pojo.User;
import com.iqik.work.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(String name, String password) {
        User user = new User();
        user.setUsername(name);
        user.setPassword(password);
        Example<User> of = Example.of(user);
        Optional<User> one = userMapper.findOne(of);
        user = one.get();
        return user;
    }
}
